package com.example.redis.controller;

import com.example.redis.cache.CacheService;
import com.example.redis.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: StringRedisTemplateController
 * @Description: TODO
 * @Author: wang xiao le
 * @Date: 2021/9/19 10:04
 **/
@RestController
@RequestMapping("/redis")
public class StringRedisTemplateController {
    @Autowired
    private CacheService cacheService;
    @Autowired
    private RedisUtil redisUtil;


    @GetMapping("/add")
    public void add() {
//        redisTemplate.opsForValue().set("test","1234");
        String test = redisUtil.get("test");
        System.out.println("test = " + test);

        cacheService.add("test", 1234);
        cacheService.get("test");
        System.out.println("test = " + test);
    }
}
